#include "wx/wxprec.h"
#if wxUSE_XRC && wxUSE_ANIMATIONCTRL

#include "wx/xrc/xh_animatctrl.h"
#include "wx/animate.h"

IMPLEMENT_DYNAMIC_CLASS( wxAnimationCtrlXmlHandler, wxXmlResourceHandler )

wxAnimationCtrlXmlHandler::wxAnimationCtrlXmlHandler() : wxXmlResourceHandler() {
  XRC_ADD_STYLE( wxAC_NO_AUTORESIZE );
  XRC_ADD_STYLE( wxAC_DEFAULT_STYLE );
  AddWindowStyles();
}

wxObject *wxAnimationCtrlXmlHandler::DoCreateResource() {
  XRC_MAKE_INSTANCE( ctrl, wxAnimationCtrl )
  ctrl->Create( m_parentAsWindow,
                GetID(),
                GetAnimation( wxT( "animation" ) ),
                GetPosition(), GetSize(),
                GetStyle( _T( "style" ), wxAC_DEFAULT_STYLE ),
                GetName() );
  // if no inactive-bitmap has been provided, GetBitmap() will return wxNullBitmap
  // which just tells wxAnimationCtrl to use the default for inactive status
  ctrl->SetInactiveBitmap( GetBitmap( wxT( "inactive-bitmap" ) ) );
  SetupWindow( ctrl );
  return ctrl;
}

bool wxAnimationCtrlXmlHandler::CanHandle( wxXmlNode *node ) {
  return IsOfClass( node, wxT( "wxAnimationCtrl" ) );
}

#endif // wxUSE_XRC && wxUSE_ANIMATIONCTRL
